//
//  REMessagesAnimator.swift
//  GoGlobalis
//
//  Created by goglobails on 2018/12/29.
//  Copyright © 2018年 Chanjinger. All rights reserved.
//

import UIKit

public typealias REMAnimationComplition = (_ complete: Bool) -> Void

public protocol REMAnimationDelegate: class {
    func hide(animator: REMessagesAnimator)
    func panStarted(animator: REMessagesAnimator)
    func panEnded(animator: REMessagesAnimator)
}

public struct REMSafeZoneConficts: OptionSet {
    
    public let rawValue: Int
    
    public init(rawValue: Int) {
        self.rawValue = rawValue
    }
    
    //消息提示框在statusBar后边
    public static let statusBar = REMSafeZoneConficts(rawValue: 1 << 0)
    //消息提示框在iphoneX系列机型的传感器后边
    public static let sensorNotch = REMSafeZoneConficts(rawValue: 1 << 1)
    //消息提示框在iphoneX系列机型导航的后边
    public static let homeIndicator = REMSafeZoneConficts(rawValue: 1 << 2)
    //消息提示框覆盖状态栏
    public static let coveredStatusBar = REMSafeZoneConficts(rawValue: 3)
}

public class REMAnimationContext {
    
    public let messageView: UIView
    public let containerView: UIView
    public let safeZoneConficts: REMSafeZoneConficts
    public let interactiveHide: Bool
    
    init(messageView: UIView, containerView: UIView, safeZoneConflicts: REMSafeZoneConficts, interactiveHide: Bool) {
        self.messageView = messageView
        self.containerView = containerView
        self.safeZoneConficts = safeZoneConflicts
        self.interactiveHide = interactiveHide
    }
}

public protocol REMessagesAnimator: class {

    var delegate: REMAnimationDelegate? { get set }
    
    func show(context: REMAnimationContext, completion: @escaping REMAnimationComplition)
    
    func hide(context: REMAnimationContext, completion: @escaping REMAnimationComplition)
}
